
import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';

class ValDeviceInfoLoader {
  static Future<String> getDeviceModel() async {
    DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
    try {
      String identity = "";
      if (Platform.isAndroid) {
        AndroidDeviceInfo build = await deviceInfoPlugin.androidInfo;
        return "Android-${build.version.sdkInt}-${build.id}";
      } else if (Platform.isIOS) {
        IosDeviceInfo data = await deviceInfoPlugin.iosInfo;
        return "${data.systemName}-${data.systemVersion}-${data.utsname.machine}";
      }
      return identity;
    } on Exception {
      return "null";
    }
  }

  static Future<String> getDeviceId() async {
    DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
    try {
      String identity = '';
      if (Platform.isAndroid) {
        AndroidDeviceInfo build = await deviceInfoPlugin.androidInfo;
        return build.id;
      } else if (Platform.isIOS) {
        IosDeviceInfo data = await deviceInfoPlugin.iosInfo;
        return data.identifierForVendor ?? '';
      }
      return identity;
    } on Exception {
      return "null";
    }
  }
}